Route all arbitrary verifier MSM terms through one storage - #186
Open
ValarDragon wants to merge 1 commit into
Open
Route all arbitrary verifier MSM terms through one storage#186ValarDragon wants to merge 1 commit into
ValarDragon wants to merge 1 commit into
Conversation
ValarDragon
force-pushed
the
agent/msm-single-storage
branch
from
August 25, 2026 09:12
9ea9091 to
e2fe378
Compare
Delete the incremental BTreeMap: append_term and add_msm now push into the same contiguous term buffer the batch verifier uses, and the single canonicalization in multiexp (sort by x, coalesce orientations) is the one place duplicate bases merge. One storage, one truth: eval and the fingerprint export cannot disagree about which representation is authoritative, scale touches one container, and the empty-buffer branch disappears. A single proof's ~60 terms sort in microseconds, replacing a BTreeMap probe per appended term. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ValarDragon
force-pushed
the
agent/msm-single-storage
branch
from
August 30, 2026 16:33
e2fe378 to
40e7193
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #182, now rebased onto
main.Summary
Deletes the incremental
BTreeMapfrom the verifierMSM:append_term,add_msm, andadd_msm_batchnow feed the same contiguousterm buffer. The shared
canonicalize_otherroutine performs the stablex-coordinate sort and orientation-aware coalescing before the selected MSM
backend consumes those terms.
One storage, one truth:
eval, the plain multiexp fallback, and the fingerprint export cannotdisagree about which representation is authoritative;
scale,add_msm, andadd_msm_batcheach touch one arbitrary-termcontainer;
multiexpis gone.Semantics are unchanged: coalescing algebra is identical (same orientation
rule and same first-encountered orientation after the stable sort), zero-scalar
entries are retained exactly as the map retained them, and identity filtering
in
append_termis untouched.Rebase integration
Current
mainadded the prepared fixed-base zero-check after this PR wasopened. The rebased prepared path canonicalizes the shared buffer in place
before converting arbitrary terms into its
extrainput. If the preparedroute declines because the extras exceed its bound, the plain
multiexpfallback re-canonicalizes that already-canonical buffer; this is idempotent.
The existing differential tests cover borrowed versus owned aggregation,
tree-shaped batch reduction, scaling, exact cancellation, opposite point
orientations, prepared versus unprepared evaluation, and fingerprint parity.
Benchmarks
Apple M4, 4 interleaved rounds, min of medians,
--features batch,multicore,baseline = #182 head:
Single-proof verification is neutral: sorting about 60 terms once costs what
about 60 map probes did. The change is a simplification, not an optimization.
Security and correctness review
No findings. Transcript-derived commitment points remain validated
CurveAffinevalues, identity filtering is unchanged, and orientationcoalescing preserves
[s](-P) = [-s]P. The storage change does not alter theFiat–Shamir transcript, verifier equation, subgroup handling, or acceptance
condition.
Validation
cargo test -p zakura-halo2-proofs --features orbits,unstable-verifier-fingerprint(116 unit tests, 5 integration tests, and doc tests)
cargo test -p zakura-halo2-proofs --no-default-features --features batch --lib poly::commitment::msm::tests(4 focused MSM tests)
cargo check --release -p zakura-halo2-proofs --no-default-features --features batchcargo fmt --all --check./scripts/changelog.py checkNo public or
pub(crate)API surface changes.